<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${base}/js/jquery.min.js"></script>
</head>
<style>
#timer_win {
	display: none;
}
table,table td,table th{
border: 1px solid gray;
border-collapse:collapse;
padding:5px;
}
</style>
<body>
	<!-- cron生成器 -->
	<div id="timer_win" class="easyui-window"
		data-options="modal:true,closed:true,minimizable:false,collapsible:false"
		style="width: 830px; height: 576px;" title="选择时间">
		<iframe src="${base}/three/cron" width="100%" height="100%"
			id="cron-iframe" scrolling:no></iframe>
	</div>
	<input class="input" type="button" onclick="block()" value="打开">
	<p />
	备注：
	<input type="text" name="content" id="content">
	<p />


	<input type="button" onclick="ok()" value="提交">

	<table style="">
		<tr>
			<th>id</<th>
			<th>cron表达式</th>
			<th>时间</th>
			<th>备注</th>
			<th>类型</th>
		</tr>
		<#if job??>
		<#list job as j>
		<tr>
			<td>${j.id!}</td>
			<td>${j.cron!}</td>
			<td>${j.time!}</td>
			<td>${j.content!}</td>
			<td><#if j.type == '2'> <a href="#" onclick="start(${j.id!})">开启</a><#else> <a href="#" onclick="end(${j.id!})">关闭</a></#if></td>
		</tr>
		</#list>
		<#else>
		<tr><td colspan="5">暂无数据</td></tr>
		</#if>
	</table>
	<script type="text/javascript">
		function block() {
			$("#timer_win").show();
		}

		function ok() {
			var content = $("#content").val();
			var cron = $('#cron-iframe').contents().find("#cron").val();
			console.log(content);
			console.log(cron);
			$.ajax({
				url : '${base}/three/addScheduler',
				type : 'post',
				dataType : 'json',
				asyns : false,
				data : {
					content : content,
					cron : cron
				},
				success : function(data) {
					alert(data.msg);
					location.reload();
				}
			})
		}
		
		function start(id){
			$.ajax({
				url : '${base}/three/schedulerStart',
				type : 'post',
				dataType : 'json',
				asyns : false,
				data : {
					id : id
				},
				success : function(data) {
					alert(data.msg);
					location.reload();
				}
			})
		}
		
		function end(id){
			$.ajax({
				url : '${base}/three/schedulerEnd',
				type : 'post',
				dataType : 'json',
				asyns : false,
				data : {
					id : id
				},
				success : function(data) {
					alert(data.msg);
					location.reload();
				}
			})
		}
		
		
	</script>
</body>
</html>